home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7727 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: news.th-darmstadt.de!news
  2. From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Constructors for objects that can be FALSE
  5. Date: Thu, 15 Feb 1996 14:16:57 +0100
  6. Organization: Fachbereich Informatik, TH Darmstadt
  7. Message-ID: <31233249.2781E494@intellektik.informatik.th-darmstadt.de>
  8. References: <4fusaq$g1e@due.unit.no>
  9. NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (X11; I; SunOS 4.1.3 sun4m)
  14.  
  15. Rolf Rustad wrote:
  16. > Hi
  17. > I'm writting control software for instrumentation applications, using BC++.
  18. > I'm creating classes, like Camera and Syntesizer etc.
  19. > What I would like is to make objects of these classes evaluate to FALSE
  20. > if the physical device is not present or available, as do for instanse
  21. > ifpstream:
  22. >  ifpstream is(filename);
  23. >  if(!is){
  24. >  .
  25. >  .
  26. >  }
  27. > How do I write the constructor??
  28.  
  29. That effect is usually achieved by providing an appropriate 
  30. conversion operator. For instance, you may add sth. like
  31.  
  32.     operator bool () const { return phys_dev_avail; }
  33.  
  34. to your class.
  35.  
  36.     Enno
  37.